﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using eschoolBO;

namespace ESCHOOL.admin
{
    public partial class WebForm8 : System.Web.UI.Page
    {
        quotes q = new quotes();
        protected void Page_Load(object sender, EventArgs e)
        {
            btnupdate.Visible = false;
            if (!IsPostBack)
            {
                DataTable dt = q.GetRecords(-99, "", false, " and ");
                GridView1.DataSource = dt;
                GridView1.DataBind();
            }
        }

        protected void btnedit_Command(object sender, CommandEventArgs e)
        {
            btninsert.Visible = false;
            btnupdate.Visible = true;
            if (e.CommandName == "Edit")
            {
                DataTable dt = q.GetRecords(Convert.ToInt64(e.CommandArgument), "", false, " and ");
                tbqid.Text = dt.Rows[0]["quote_id"].ToString();
                tbquote.Text = dt.Rows[0]["quote"].ToString();
            }
        }

        protected void btndelete_Command(object sender, CommandEventArgs e)
        {
            if (e.CommandName == "Delete")
            {
                DataTable dt = q.GetRecords(Convert.ToInt64(e.CommandArgument),"",false," and ");
                q.quote_id = Convert.ToInt64(dt.Rows[0]["quote_id"].ToString());
                q.quote = dt.Rows[0]["quote"].ToString();
                q.isdeleted = true;
                q.SaveRecords();
                Response.Redirect("~/admin/Quote.aspx");
            }
        }

        protected void btninsert_Click(object sender, EventArgs e)
        {
            q.quote_id = -99;
            q.quote = tbquote.Text;
            q.isdeleted = false;
            q.SaveRecords();
            Response.Redirect("~/admin/Quote.aspx");

        }

        protected void btnupdate_Click(object sender, EventArgs e)
        {
            q.quote_id = Convert.ToInt64(tbqid.Text);
            q.quote = tbquote.Text;
            q.isdeleted = false;
            q.SaveRecords();
            Response.Redirect("~/admin/Quote.aspx");

        }

        protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
        {

        }

        protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {

        }
    }
}
